import { Button, Space, Popconfirm } from 'ant-design-vue';
import { defineComponent } from 'vue';

/**
 * 生VxeTable工具栏按钮
 * @param record  行记录
 * @param createCall  创建按钮事件
 * @param deleteCall  删除按钮事件
 * @returns
 */
export default defineComponent({
  props: {
    record: {
      type: Object,
      default: () => {
        return {};
      }
    },
    editCall: {
      type: Function,
      default: () => { }
    },
    deleteCall: {
      type: Function,
      default: () => { }
    }
  },
  emits: ['edit', 'delete'],
  setup(props, { emit }) {
    const handleEdit = (_arg: any) => {
      emit('edit', props.record);
    };
    const handleDelete = (_arg: any) => {
      emit('delete', props.record);
    };
    return {
      handleEdit,
      handleDelete
    };
  },
  render() {
    return (
      <Space>
        <Button
          type="dashed"
          size='small'
          onClick={this.handleEdit}
          v-permission={'sysMenu:update'}
        >
          编辑
        </Button>
        <Popconfirm title="确定要删除数据？" onConfirm={this.handleDelete}>
          <Button type="dashed" size='small' danger v-permission={'sysMenu:delete'}>
            删除
          </Button>
        </Popconfirm>
      </Space>
    );
  }
});
